

#metadef
#idString Rigol Technologies,DG811,
#name Rigol DG811
#handle DG811

#replaceText MaxFrequency 10M 
#replaceText MinPeriod 100.000n

#metadef
#idString Rigol Technologies,DG812,
#name Rigol DG812
#handle DG812

#replaceText MaxFrequency 10M 
#replaceText MinPeriod 100.000n

#metadef
#idString Rigol Technologies,DG822,
#name Rigol DG822
#handle DG822

#replaceText MaxFrequency 25M 
#replaceText MinPeriod 40.000n

#metadef
#idString Rigol Technologies,DG821,
#name Rigol DG821
#handle DG821

#replaceText MaxFrequency 25M 
#replaceText MinPeriod 40.000n

#metadef
#idString Rigol Technologies,DG832,
#name Rigol DG832
#handle DG832

#replaceText MaxFrequency 35M 
#replaceText MinPeriod 29.000n

#metadef
#idString Rigol Technologies,DG831,
#name Rigol DG831
#handle DG831

#replaceText MaxFrequency 35M 
#replaceText MinPeriod 29.000n

#metadef
#idString Rigol Technologies,DG952,
#name Rigol DG952
#handle DG952

#replaceText MaxFrequency 50M 
#replaceText MinPeriod 20.000n

#metadef
#idString Rigol Technologies,DG972,
#name Rigol DG972
#handle DG972

#replaceText MaxFrequency 70M 
#replaceText MinPeriod 14.200n


#metadef
#idString Rigol Technologies,DG992,
#name Rigol DG992
#handle DG992

#replaceText MaxFrequency 100M 
#replaceText MinPeriod 10.000n


#meta

; Source originally from HKJ and HBO.
; 22 Jun 21	HBO	First version
#author bateau020


#idString Rigol Technologies,DG992,
#name Rigol DG992
#handle DG992
#port lxi

; Format of answers: f=float, u=remove trailing letters, x=skip, *=Zero upper case values if this value is 0

; A list of possible column name with unit and formatter (SI, Time, Int, D0..D6)
#value Frequency1 Hz SI 
#value Amplitude1 V SI 
#value Offset1 V SI
#value Frequency2 Hz SI 
#value Amplitude2 V SI 
#value Offset2 V SI 


; How to poll for data, this is used for table and #values?
; a #askMode, #cmdMode and #prepareSample is used before this is string is used.
; This is a single line command

#askValues :SOUR1:APPL?;:SOUR2:APPL?
#askModeMathFormat unQuote(value);
#askValuesReadFormat xfffxxfffx


; Switch meter to this mode during start, leave empty to avoid any switching
#initialMode 


; Prepare the meter to response to #askValues
;#prepareSample 


; Initial commands to meter when establishing connection
#initCmd


; Final command to meter before breaking connection
#finalCmd :OUTP1 OFF;:OUTP2 OFF

#outputOff :OUTP1 OFF;:OUTP2 OFF

#interfaceType ARB ARB:2
#interface setFrequency :SOUR(channel):FREQ (value)
#interface setAmplitude :SOUR(channel):VOLT (value)
#interface setOffset :SOUR(channel):VOLT:OFFS (value)
#interface setWaveform :SOUR(channel):FUNC (value)
#interface setOn :OUTP(channel) (getElement("off on",value," "))

; :SOUR1:APPL? Queries the waveform type as well as the frequency, amplitude, offset, and phase of CH1

#interface getFrequency :SOUR(channel):APPL?
:readmath: getElement(unQuote(value),1,",")
:readformat: u
#interface getAmplitude :SOUR(channel):APPL?
:readmath: getElement(unQuote(value),2,",")
:readformat: u
#interface getOffset :SOUR(channel):APPL?
:readmath: getElement(unQuote(value),3,",")
:readformat: u
#interface getWaveform :SOUR(channel):APPL?
:string:
:readmath: getElement(unQuote(value),0,",")
#interface getOn :OUTP(channel)?
:readmath: listIndex(getMatch(value,"(ON)|(OFF)"),"OFF ON"," ")
#interface readFrequency 0 4 
#interface readAmplitude 1 5
#interface readOffset 2 6
#interface readDutyCycle 3 7


; Strings to configure device in different modes
; First parameter must match a #value (4 parameter) and second parameter must match what #askMode returns
; First parameter is also used in shortcut menu
;#cmdMode 

; Setup menu functions
; The parameters on the first line is: type name page 
; Settings on the following lines are:
; read: SCPI to read value from device, is used to synchronize when opening setup page or setting equal named fields. Not always used
; readformat: Parse read value.
; write: Send the value to device, this field is used in combination with data fields in the details to send updates to device.
; tip: Add this tip to all components for this input field.

;--------------------------------------------------------------------------------------

#cmdSetup color _ Output_1
(200,0,0)


#cmdSetup indicator State Output_1
:read: :OUTP1?
:updatealloff:
off 0 red
on getMatch(value,"(ON)|(OFF)")=="ON" red

#cmdSetup buttons State Output_1
:write: :OUTP1
Off off
On on

#cmdSetup combobox Waveform Output_1
:write: :SOUR1:APPL:# 
:read: :SOUR1:APPL?
:readmath: getElement(unQuote(value),0,",")
:update: Frequency Period Amplitude Amplitude_unit Offset Square_duty_cyclequare Pulse_duty_cycleulse Symmetry Arbitrary
:updatedelayed: 0.1 
Sine SIN
Square SQU
Ramp RAMP
Pulse PULSE
Noise NOISE
Arbitrary ARB
DC DC
; yes, when I set USER, I get ARB back, so use ARB


; TODO Allow arbitray waveform. This here below is from siglent, to be adapted of course
;#cmdSetup numberint Arbitrary Output_1
;:write: c1:ARWV INDEX,# 
;:read: c1:ARWV?
;:readmath: getElement(value,1,",")
;:enable: inList(Output_1.Waveform,"USER");
;_ 0 196

#cmdSetup number Frequency FREQ_1
:read: :SOUR1:APPL?
:readmath: getElement(unQuote(value),1,",")
:readformat: u
:textwidth: 8
:update: Period
:write: :SOUR1:FREQ #
:tip: MaxFrequency is only possible in sine mode.
:updatemodechange:
Hz 100p MaxFrequency

#cmdSetup number Period FREQ_1
:read: :SOUR1:PER?
:readmath: value
:readformat: u
:write: :SOUR1:PER #
:textwidth: 8
:update: Frequency
:tip: MinPeriod is only possible in sine mode.
:updatemodechange:
s MinPeriod 10G

#cmdSetup number Amplitude AMPL_1
:read: :SOUR1:VOLT?
:readmath: value
:readformat: u
:write: :SOUR1:VOLT #
:textwidth: 8
:update: AMPL_1.Amplitude_unit AMPL_1.High_Level AMPL_1.Low_Level AMPL_1.Offset
:tip: Vpp Amplitude + offset must be within +/-10V. Limits depend on load Z and unit.
:updatemodechange:
V 1m 20

#cmdSetup combobox Amplitude_unit AMPL_1
:write: :SOUR1:VOLT:UNIT # 
:read: :SOUR1:VOLT:UNIT?
:update: AMPL_1.Amplitude AMPL_1.High_Level AMPL_1.Low_Level AMPL_1.Offset
:tip: 
:updatemodechange:
Vpp VPP
Vrms VRMS
dBm DBM

#cmdSetup number High_Level AMPL_1
:read: :SOUR1:VOLT:HIGH?
:readmath: value
:readformat: u
:textwidth: 8
:update: AMPL_1.Amplitude AMPL_1.Amplitude_unit AMPL_1.Low_Level AMPL_1.Offset
:write: :SOUR1:VOLT:HIGH #
:tip: Must be > Low Level. Limits depend on load Z.
:updatemodechange:
V -10 10

#cmdSetup number Low_Level AMPL_1
:read: :SOUR1:VOLT:LOW?
:readmath: value
:readformat: u
:textwidth: 8
:update: AMPL_1.Amplitude AMPL_1.Amplitude_unit AMPL_1.High_Level AMPL_1.Offset
:write: :SOUR1:VOLT:LOW #
:tip: Must be < High Level. Limits depend on load Z.
:updatemodechange:
V -10 10

#cmdSetup number Offset AMPL_1
:read: :SOUR1:VOLT:OFFS?
:readmath: value
:readformat: u
:textwidth: 8
:update: AMPL_1.Amplitude AMPL_1.Amplitude_unit AMPL_1.High_Level AMPL_1.Low_Level
:write: :SOUR1:VOLT:OFFS #
:tip: Vpp Amplitude + offset must be within +/-10V. Limits depend on load Z.
:updatemodechange:
V -10 10

#cmdSetup number Ampl._Cal._Z AMPL_1
:read: :OUTP1:IMP?
:readmath: value
:readformat: u
:write: :OUTP1:IMP #
:textwidth: 8
:tip: Calibrates Amplitude settings to match the actual load
:emptyvalue: 0
:emptywrite: :OUTP1:IMP INF
:updatemodechange:
Ohms 1 10k

#cmdSetup number Offset Offset_1
:read: :SOUR1:VOLT:OFFS?
:readmath: value
:readformat: u
:textwidth: 8
:write: :SOUR1:VOLT:OFFS #
:tip: Vpp Amplitude + offset must be within +/-10V. Limits depend on load Z.
:updatemodechange:
V -10 10

#cmdSetup number Phase PHASE_1
:read: :SOUR1:PHAS?
:readmath: value
:readformat: u
:write: :SOUR1:PHAS #
:textwidth: 8
:tip: Phase of the signal.
:updatemodechange:
deg 0 360

#cmdSetup number Symmetry RAMP_1
:read: :SOUR1:FUNC:RAMP:SYMM?
:readmath: value
:readformat: u
:textwidth: 8
:write: SOUR1:FUNC:RAMP:SYMM #
:tip: Symmetry for ramp
:updatemodechange:
% 0 100

#cmdSetup number Duty_cycle Square_1
:read: :SOUR1:FUNC:SQU:DCYCLE?
:readmath: value
:readformat: u
:textwidth: 8
:write: SOUR1:FUNC:SQU:DCYCLE #
:tip: Duty cycle for square
:updatemodechange:
% 0 100

#cmdSetup number Duty_cycle Pulse_1
:read: :SOUR1:FUNC:PULSE:DCYCLE?
:readmath: value
:readformat: u
:textwidth: 8
:update: Pulse_1.Width Pulse_1.Rise Pulse_1.Fall
:write: SOUR1:FUNC:PULSE:DCYCLE #
:tip: Duty cycle for pulse
:updatemodechange:
% 0 100

#cmdSetup number Width Pulse_1
:read: :SOUR1:FUNC:PULSE:WIDTH?
:readmath: value
:readformat: u
:textwidth: 8
:update: Pulse_1.Duty_cycle Pulse_1.Rise Pulse_1.Fall
:write: SOUR1:FUNC:PULSE:WIDTH #
:tip: Pulse Width
:updatemodechange:
s MinPeriod 10G

#cmdSetup number Rise_time Pulse_1
:read: :SOUR1:FUNC:PULSE:TRAN:LEAD?
:readmath: value
:readformat: u
:textwidth: 8
:update: Pulse_1.Duty_cycle Pulse_1.Width Pulse_1.Fall
:write: SOUR1:FUNC:PULSE:TRAN:LEAD #
:tip: Pulse Rising edge, up to 0.625 x pulse width
:updatemodechange:
s MinPeriod 10G

#cmdSetup number Fall_time Pulse_1
:read: :SOUR1:FUNC:PULSE:TRAN:TRA?
:readmath: value
:readformat: u
:textwidth: 8
:update: Pulse_1.Duty_cycle Pulse_1.Width Pulse_1.Rise
:write: SOUR1:FUNC:PULSE:TRAN:TRA #
:tip: Pulse Falling edge, up to 0.625 x pulse width
:updatemodechange:
s MinPeriod 10G

#cmdSetup selector Settings_1 Output_1
Output_1.Waveform
:updatemodechange:
SIN FREQ_1. AMPL_1. PHASE_1.
SQU FREQ_1. AMPL_1. PHASE_1. Square_1.
RAMP FREQ_1. AMPL_1. PHASE_1. RAMP_1.
PULSE FREQ_1. AMPL_1. PHASE_1. Pulse_1.
NOISE AMPL_1. 
ARB FREQ_1. AMPL_1. PHASE_1.
DC Offset_1.

;--------------------------------------------------------------------------------------

#cmdSetup color _ Output_2
(0,0,200)

#cmdSetup indicator State Output_2
:read: :OUTP2?
:updatealloff:
off 0 red
on getMatch(value,"(ON)|(OFF)")=="ON" red

#cmdSetup buttons State Output_2
:write: :OUTP2
Off off
On on

#cmdSetup combobox Waveform Output_2
:write: :SOUR2:APPL:# 
:read: :SOUR2:APPL?
:readmath: getElement(unQuote(value),0,",")
:update: Frequency Period Amplitude Amplitude_unit Offset Square_duty_cyclequare Pulse_duty_cycleulse Symmetry Arbitrary
:updatedelayed: 0.1 
Sine SIN
Square SQU
Ramp RAMP
Pulse PULSE
Noise NOISE
Arbitrary ARB
DC DC
; yes, when I set USER, I get ARB back, so use ARB


; TODO Allow arbitray waveform. This here below is from siglent, to be adapted of course
;#cmdSetup numberint Arbitrary Output_2
;:write: c1:ARWV INDEX,# 
;:read: c1:ARWV?
;:readmath: getElement(value,1,",")
;:enable: inList(Output_2.Waveform,"USER");
;_ 0 196

#cmdSetup number Frequency FREQ_2
:read: :SOUR2:APPL?
:readmath: getElement(unQuote(value),1,",")
:readformat: u
:textwidth: 8
:update: Period
:write: :SOUR2:FREQ #
:tip: MaxFrequency is only possible in sine mode.
:updatemodechange:
Hz 100p MaxFrequency

#cmdSetup number Period FREQ_2
:read: :SOUR2:PER?
:readmath: value
:readformat: u
:write: :SOUR2:PER #
:textwidth: 8
:update: Frequency
:tip: MinPeriod is only possible in sine mode.
:updatemodechange:
s MinPeriod 10G

#cmdSetup number Amplitude AMPL_2
:read: :SOUR2:VOLT?
:readmath: value
:readformat: u
:write: :SOUR2:VOLT #
:textwidth: 8
:update: AMPL_2.Amplitude_unit AMPL_2.High_Level AMPL_2.Low_Level AMPL_2.Offset
:tip: Vpp Amplitude + offset must be within +/-10V. Limits depend on load Z and unit.
:updatemodechange:
V 1m 20

#cmdSetup combobox Amplitude_unit AMPL_2
:write: :SOUR2:VOLT:UNIT # 
:read: :SOUR2:VOLT:UNIT?
:update: AMPL_2.Amplitude AMPL_2.High_Level AMPL_2.Low_Level AMPL_2.Offset
:tip: 
:updatemodechange:
Vpp VPP
Vrms VRMS
dBm DBM

#cmdSetup number High_Level AMPL_2
:read: :SOUR2:VOLT:HIGH?
:readmath: value
:readformat: u
:textwidth: 8
:update: AMPL_2.Amplitude AMPL_2.Amplitude_unit AMPL_2.Low_Level AMPL_2.Offset
:write: :SOUR2:VOLT:HIGH #
:tip: Must be > Low Level. Limits depend on load Z.
:updatemodechange:
V -10 10

#cmdSetup number Low_Level AMPL_2
:read: :SOUR2:VOLT:LOW?
:readmath: value
:readformat: u
:textwidth: 8
:update: AMPL_2.Amplitude AMPL_2.Amplitude_unit AMPL_2.High_Level AMPL_2.Offset
:write: :SOUR2:VOLT:LOW #
:tip: Must be < High Level. Limits depend on load Z.
:updatemodechange:
V -10 10

#cmdSetup number Offset AMPL_2
:read: :SOUR2:VOLT:OFFS?
:readmath: value
:readformat: u
:textwidth: 8
:update: AMPL_2.Amplitude AMPL_2.Amplitude_unit AMPL_2.High_Level AMPL_2.Low_Level
:write: :SOUR2:VOLT:OFFS #
:tip: Vpp Amplitude + offset must be within +/-10V. Limits depend on load Z.
:updatemodechange:
V -10 10

#cmdSetup number Ampl._Cal._Z AMPL_2
:read: :OUTP2:IMP?
:readmath: value
:readformat: u
:write: :OUTP2:IMP #
:textwidth: 8
:tip: Calibrates Amplitude settings to match the actual load
:emptyvalue: 0
:emptywrite: :OUTP2:IMP INF
:updatemodechange:
Ohms 1 10k

#cmdSetup number Offset Offset_2
:read: :SOUR2:VOLT:OFFS?
:readmath: value
:readformat: u
:textwidth: 8
:write: :SOUR2:VOLT:OFFS #
:tip: Vpp Amplitude + offset must be within +/-10V. Limits depend on load Z.
:updatemodechange:
V -10 10

#cmdSetup number Phase PHASE_2
:read: :SOUR2:PHAS?
:readmath: value
:readformat: u
:write: :SOUR2:PHAS #
:textwidth: 8
:tip: Phase of the signal.
:updatemodechange:
deg 0 360

#cmdSetup number Symmetry RAMP_2
:read: :SOUR2:FUNC:RAMP:SYMM?
:readmath: value
:readformat: u
:textwidth: 8
:write: SOUR2:FUNC:RAMP:SYMM #
:tip: Symmetry for ramp
:updatemodechange:
% 0 100

#cmdSetup number Duty_cycle Square_2
:read: :SOUR2:FUNC:SQU:DCYCLE?
:readmath: value
:readformat: u
:textwidth: 8
:write: SOUR2:FUNC:SQU:DCYCLE #
:tip: Duty cycle for square
:updatemodechange:
% 0 100

#cmdSetup number Duty_cycle Pulse_2
:read: :SOUR2:FUNC:PULSE:DCYCLE?
:readmath: value
:readformat: u
:textwidth: 8
:update: Pulse_2.Width Pulse_2.Rise Pulse_2.Fall
:write: SOUR2:FUNC:PULSE:DCYCLE #
:tip: Duty cycle for pulse
:updatemodechange:
% 0 100

#cmdSetup number Width Pulse_2
:read: :SOUR2:FUNC:PULSE:WIDTH?
:readmath: value
:readformat: u
:textwidth: 8
:update: Pulse_2.Duty_cycle Pulse_2.Rise Pulse_2.Fall
:write: SOUR2:FUNC:PULSE:WIDTH #
:tip: Pulse Width
:updatemodechange:
s MinPeriod 10G

#cmdSetup number Rise_time Pulse_2
:read: :SOUR2:FUNC:PULSE:TRAN:LEAD?
:readmath: value
:readformat: u
:textwidth: 8
:update: Pulse_2.Duty_cycle Pulse_2.Width Pulse_2.Fall
:write: SOUR2:FUNC:PULSE:TRAN:LEAD #
:tip: Pulse Rising edge, up to 0.625 x pulse width
:updatemodechange:
s MinPeriod 10G

#cmdSetup number Fall_time Pulse_2
:read: :SOUR2:FUNC:PULSE:TRAN:TRA?
:readmath: value
:readformat: u
:textwidth: 8
:update: Pulse_2.Duty_cycle Pulse_2.Width Pulse_2.Rise
:write: SOUR2:FUNC:PULSE:TRAN:TRA #
:tip: Pulse Falling edge, up to 0.625 x pulse width
:updatemodechange:
s MinPeriod 10G

#cmdSetup selector Settings_2 Output_2
Output_2.Waveform
:updatemodechange:
SIN FREQ_2. AMPL_2. PHASE_2.
SQU FREQ_2. AMPL_2. PHASE_2. Square_2.
RAMP FREQ_2. AMPL_2. PHASE_2. RAMP_2.
PULSE FREQ_2. AMPL_2. PHASE_2. Pulse_2.
NOISE AMPL_2. 
ARB FREQ_2. AMPL_2. PHASE_2.
DC Offset_2.